FROM node:20-alpine as builder

COPY package.json /app/
WORKDIR /app

ARG Registry
RUN [ ! -n "$Registry" ] || npm config set registry ${Registry}
RUN npm config get registry

RUN npm install --loglevel warn
COPY . .

ARG BUILD_ENV
RUN npm run build:$BUILD_ENV;

FROM nginx:stable
WORKDIR /app
COPY nginx/nginx.conf /etc/nginx/
COPY --from=builder /app/dist/ /usr/share/nginx/html/
EXPOSE 80